﻿namespace ProblemsSet
{
    public class Problem_131 : BaseProblem
    {
        public override object GetResult()
        {
            const int max = 1000000;

            MathLogic.GetPrimeList(max, true);

            long count = 0;

            for (long q = 1; q <= long.MaxValue; q ++ )
            {
                var p = 3*q*q + 3*q + 1;
                if (p >= max)
                    break;
                if (MathLogic.IsPrimeNumber(p, true))
                    count++;
            }

            return count;
        }

        public override string Problem
        {
            get
            {
                return @"There are some prime values, p, for which there exists a positive integer, n, such that the expression n3 + n2p is a perfect cube.

For example, when p = 19, 83 + 8219 = 123.

What is perhaps most surprising is that for each prime with this property the value of n is unique, and there are only four such primes below one-hundred.

How many primes below one million have this remarkable property?";
            }
        }

        public override bool IsSolved
        {
            get
            {
                return true;
            }
        }

        public override object Answer
        {
            get
            {
                return 173;
            }
        }
    }
}
